Everyone knows that the best way to get something done on the Internet is with an inflammatory title and a potentially incorrect contention, so here goes. What do you if you want to capture/log the filename of an assertion? Prior to C++20, you use good old __FILE__, which gives you a C-style array of chars.… Continue reading std::source_location is Broken
Modern C++? How about Contemporary C++?
What does “modern C++” mean? Some say it started in 2001 with Andrei Alexandrescu’s book Modern C++ Design. A lot of people describe C++11 and C++14 as modern; others say, “It’s time to stop calling C++11/14 modern C++, it’s not modern anymore.” Here’s another idea. The art world already settled this, so let’s take a… Continue reading Modern C++? How about Contemporary C++?
In Support of Implication for C++
The paper: https://wg21.link/p2971 I have a deck of cards. Each card has a number (integer) on the front, and is either red or blue on the back. (This is axiomatic, I know it a priori). My friend lays out four cards on the table in front of us at random. I see two face up,… Continue reading In Support of Implication for C++
Monads are part of C++, and are in your code
For several reasons, I didn’t get a CppCon ticket this year, but since I live in the Denver metro area I did go on the Friday, which is free to attend. Herb’s closing keynote (Cpp2) was thought provoking. At one point though, he said, Think about the words and the ideas that we have been… Continue reading Monads are part of C++, and are in your code
C++23’s new function syntax
We’ve had a couple of ways to spell functions for a long time: And we’ve had a shortcut for that second one for a while, too: (Aside: notice where [[nodiscard]] is positioned, since C++23’s P2173, to apply to the lambda’s call operator.) All these ways to spell functions look the same at the call site.… Continue reading C++23’s new function syntax
constexpr Function Parameters
The Set-up In C++, this doesn’t work: The compiler complains, quite rightly: Despite the fact that twice_square is a constexpr function, its parameter x is not constexpr. We can’t use it in a static_assert, we can’t pass it to a template, we can’t call an immediate (consteval) function with it. So far, so well known.… Continue reading constexpr Function Parameters
Familiar Template Syntax IILEs
A lot has already been said in the blogosphere about the use of immediately-invoked lambda expressions (IILEs) for initialization, and they’re certainly very useful. In C++20, P0428 gives us “familiar template syntax” for lambdas. Now, instead of writing a regular generic lambda: we have the option to use “familiar template syntax” to name the template… Continue reading Familiar Template Syntax IILEs
Remember the Vasa! or, plus ça change, plus c’est la même chose
I’ve been programming in C++ for almost a quarter of a century now. I grew up, professionally, with C++, and in many ways, it grew up along with me. For someone who is used to C++, even used to recently-standardised C++, it’s hard not to feel apprehension when looking at C++20. Modules, coroutines, ranges, concepts… Continue reading Remember the Vasa! or, plus ça change, plus c’est la même chose
Thoughts on Modern C++ and Game Dev
TL;DR: The C++ committee isn’t following some sort of agenda to ignore the needs of game programmers, and “modern” C++ isn’t going to become undebuggable. — Over the past week there has been an ongoing conversation on Twitter about how many people — especially those in the games industry — feel that the current direction… Continue reading Thoughts on Modern C++ and Game Dev
Pointer-to-member-functions can be tricky
Note: the following applies to Microsoft’s compiler only — not to GCC or Clang. Pointers-to-member-functions (PMFs) are a bit off the beaten track in C++. They aren’t very syntactically pleasing, and they aren’t as easy to deal with as regular pointers-to-free-functions (PFFs). But they still see use, particularly in pre-C++11 codebases or where people choose… Continue reading Pointer-to-member-functions can be tricky